package wang.hu.bos.mq.service;

import javax.jms.JMSException;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.springframework.stereotype.Service;

@Service("msgConsumer")
public class MsgConsumer implements MessageListener {

	@Override
	public void onMessage(Message message) {
		MapMessage mapMessage = (MapMessage) message;
		try {
			/*
			 * String result = SmsUtils.sendSmsByHTTP(
			 * mapMessage.getString("telephone"),
			 * mapMessage.getString("content"));
			 */
			String result = "000x";
			if (result.startsWith("000")) {
				System.out.println("短信验证码发送成功,验证短信为:"
						+ mapMessage.getString("content"));
			} else {
				throw new RuntimeException("验证短信发送失败,状态码为:" + result);
			}
		} catch (JMSException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
